package com.walsai.pcsys.core.model;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Transient;

@Entity
public class Solution extends BaseObject implements Serializable{
	private static final long serialVersionUID = 1258437622L;
	
	public static final int PERMISSION_PUBLIC = 0;
	public static final int PERMISSION_PRIVATE = 1;
	
	private SolutionPK solutionPK;
	private Timestamp submitDate;
	private int permission;
	private String language;
	private byte[] codeFile;
	
	@EmbeddedId
	public SolutionPK getSolutionPK() {
		return solutionPK;
	}
	
	@Column(nullable=false)
	public Timestamp getSubmitDate() {
		return submitDate;
	}
	
	@Column(nullable=false)
	public int getPermission() {
		return permission;
	}
	
	@Column(nullable=false)
	public String getLanguage() {
		return language;
	}
	
	@Transient
	public byte[] getCodeFile() {
		return codeFile;
	}
	
	
	public void setSolutionPK(SolutionPK solutionPK){
		this.solutionPK = solutionPK;
	}
	public void setSubmitDate(Timestamp submitDate) {
		this.submitDate = submitDate;
	}
	public void setPermission(int permission) {
		this.permission = permission;
	}
	public void setLanguage(String language) {
		this.language = language;
	}
	public void setCodeFile(byte[] codeFile) {
		this.codeFile = codeFile;
	}

	@Override
	public boolean equals(Object o) {
        boolean result = false;
        if (o != null && getClass() == o.getClass()) {
            final Solution p = (Solution) o;
            if (this.solutionPK.equals(p.solutionPK)) {
                result = true;
            }
        }
        return result;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
	

}
